﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using CLEX.Service.DataContracts;

namespace CLEX.Client.Metro.ViewModel.Lattice
{
    public class HistogramDeleteVM : VMBase
    {
        private readonly IPopupService popup;
        private readonly LatticeState state;
        private readonly AggregateData aggregate;
        private readonly RelayCommand delete;
        private readonly RelayCommand cancel;

        public string AggregateName
        {
            get { return string.Format("{0}({1})", aggregate.AggregateType.ToString(), aggregate.Column); }
        }

        public ICommand Delete
        {
            get { return delete; }
        }

        public ICommand Cancel
        {
            get { return cancel; }
        }

        public HistogramDeleteVM(IPopupService popup, LatticeState state, AggregateData aggregate)
        {
            this.popup = popup;
            this.state = state;
            this.aggregate = aggregate;
            this.delete = new RelayCommand(DoDelete);
            this.cancel = new RelayCommand(DoCancel);
        }

        private void DoDelete()
        {
            state.RemoveAggregate(aggregate);
            popup.ClosePopup();
        }

        private void DoCancel()
        {
            popup.ClosePopup();
        }
    }
}
